import {BASENUMBER} from "@/types/constant";

export class BaseForm {
    id: any = "" //后台id字段
    name: string = ""  //Token简称
    symbol: string = ""  //Token全称
    total: any = ""  //发行数量
    owner: string = ""//接收地址
    introduction: string = "" //Token简介
    category: any = 1//是否增加发 0 为普通token， 1 可增发和燃烧
    platform_id: any = 0//钱包平台ID
    chain_id: string = ""//平行链
    exer: string = "" // 执行器
    chain_name: string = ""

    constructor() {
    }

    //校验为空 true通过
    checkRequire() {
        if (this.name != ""
            && this.symbol != ""
            && this.total != "" //发行数量
            && this.owner != ""//接收地址
            && this.introduction != "" //Token简介
            && this.chain_id != ""//平行链
        ) {
            return true
        } else {
            return false
        }
    }

    //重置发行数量
    resetTotal() {
        let value = Number(this.total)
        if (this.total && value > BASENUMBER) {
            this.total = this.total / BASENUMBER
        } else if (this.total && value < BASENUMBER) {
        } else {
            this.total = "";
        }
    }

    //清空方法
    reset() {
        this.name = ""  //Token简称
        this.symbol = ""  //Token全称
        this.total = ""  //发行数量
        this.owner = ""//接收地址
        this.introduction = "" //Token简介
        this.category = 0//是否增加发 0 为普通token， 1 可增发和燃烧
        this.platform_id = ""//钱包平台ID
        this.chain_id = ""//平行链名称
    }
}